<?php


namespace app\common\model;


class TeacherCourse extends BaseModel
{
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function teacher()
    {
        return $this->hasOne(Teacher::class, 'teacher_id', 'teacher_id');
    }

    public function language()
    {
        return $this->hasOne(Language::class, 'language_id', 'language_id');
    }

    public function course()
    {
        return $this->hasMany(Course::class, 'teacher_course_id', 'teacher_course_id')->where('status', 4);
    }

    public function grade()
    {
        return $this->hasOne(LanguageGrade::class, 'language_grade_id', 'language_grade_id');
    }

    public static function getColumnByCourseId($teacherCourseId, $column)
    {
        return self::where('teacher_course_id', $teacherCourseId)->value($column);
    }

}